package com.sailorj.medical.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.sailorj.medical.domain.chronicdis.Chronicdis;
import com.sailorj.medical.exception.DbException;

/**
 * 慢性病信息查询DAO类
 */
public class ChronicdisDao extends GenericDao<Chronicdis> {

	@Override
	protected Chronicdis handle(ResultSet rs) throws SQLException {

		Chronicdis entity = new Chronicdis();

		entity.setIllcode(rs.getString("illcode"));// 疾病编码
		entity.setIllname(rs.getString("illname"));// 疾病名称
		entity.setPycode(rs.getString("pycode"));// 拼音码
		entity.setWbcode(rs.getString("wbcode"));// 五笔码

		return entity;
	}

	public List<Chronicdis> findByKeyValue(String key, String value) throws DbException {
		try {
			String sqlSB = "";
			StringBuffer sb = new StringBuffer(1024);
			if (key != null && value != null) {
				sqlSB = sb.append(" and " + key + "='" + value + "'").toString();
			}
			String sql = "select * from t_chronicdis where 1=1 " + sqlSB + "";

			Object[] params = {};

			return super.queryOjects(sql, params);

		} catch (SQLException e) {
			throw new DbException("慢性病证信息查询失败!", e);
		}
	}
}
